From ae3207e9778c3f2fb01d64714ff15fc073ec093d Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 1 Dec 2023 10:16:12 +0700 Subject: Update compute different, result, and product list feature --- src/app/api/product/[id]/toggle-different/route.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/app/api/product/[id]/toggle-different/route.tsx (limited to 'src/app/api/product/[id]/toggle-different') diff --git a/src/app/api/product/[id]/toggle-different/route.tsx b/src/app/api/product/[id]/toggle-different/route.tsx new file mode 100644 index 0000000..987dbf3 --- /dev/null +++ b/src/app/api/product/[id]/toggle-different/route.tsx @@ -0,0 +1,16 @@ +import { NextRequest, NextResponse } from "next/server"; +import { prisma } from "prisma/client"; + +type Params = { params: { id: string } } +export async function POST(request: NextRequest, { params }: Params) { + const intId = parseInt(params.id) + const product = await prisma.product.findUnique({ where: { id: intId } }) + const updatedProduct = await prisma.product.update({ + where: { id: intId }, + data: { + isDifferent: !product?.isDifferent + } + }) + + return NextResponse.json(updatedProduct) +} \ No newline at end of file -- cgit v1.2.3